package com.yanqu.road.server.manger.activity.sonhai.pb;

import com.yanqu.road.entity.activity.sonhai.config.*;
import com.yanqu.road.entity.activity.sonhai.data.SonHaiServerUserData;
import com.yanqu.road.entity.activity.sonhai.data.SonHaiUserMallData;
import com.yanqu.road.pb.activity.SonHaiProto;
import com.yanqu.road.server.manger.ServerLanguageMgr;

public class SonHaiActivityPb {

    /**
     * builder SonHaiEventConfig
     * @param eventConfig
     * @return
     */
    public static SonHaiProto.SonHaiEventConfig.Builder buildSonHaiEventConfig(SonHaiEventConfig eventConfig, String language) {
        SonHaiProto.SonHaiEventConfig.Builder builder = SonHaiProto.SonHaiEventConfig.newBuilder();
        builder.setId(eventConfig.getId());
        builder.setIcon(eventConfig.getIcon());
        builder.setEventType(eventConfig.getEventType());
        builder.setName(ServerLanguageMgr.getContent(eventConfig.getName(), language));
        builder.setMonster(eventConfig.getMonster());
        builder.setEventDesc(ServerLanguageMgr.getContent(eventConfig.getEventDesc(), language));
        builder.setDesc(ServerLanguageMgr.getContent(eventConfig.getDesc(), language));
        builder.setSimpleDesc(ServerLanguageMgr.getContent(eventConfig.getSimpleDesc(), language));
        builder.setLevel(eventConfig.getLevel());
        builder.setParam(eventConfig.getParam());
        builder.setReward(eventConfig.getReward());
        builder.setSchedule(eventConfig.getSchedule());
        builder.setMonsterScore(eventConfig.getMonsterScore());
        builder.setPvpScore(eventConfig.getPvpScore());
        return builder;
    }

    /**
     * builder SonHaiFloorConfig
     * @param floorConfig
     * @return
     */
    public static SonHaiProto.SonHaiFloorConfig.Builder buildSonHaiFloorConfig(SonHaiFloorConfig floorConfig, String language) {
        SonHaiProto.SonHaiFloorConfig.Builder builder = SonHaiProto.SonHaiFloorConfig.newBuilder();
        builder.setId(floorConfig.getId());
        builder.setFloor(floorConfig.getFloor());
        builder.setName(ServerLanguageMgr.getContent(floorConfig.getName(), language));
        builder.setEnergy(floorConfig.getEnergy());
        builder.setNeedSchedule(floorConfig.getNeedSchedule());
        builder.setSpecial(floorConfig.getSpecial());
        builder.setEventWeight(floorConfig.getEventWeight());
        builder.setEventNum(floorConfig.getEventNum());
        builder.setBuffWeight(floorConfig.getBuffWeight());
        builder.setMonsterHpAdd(floorConfig.getMonsterHpAdd());
        builder.setPower(floorConfig.getPower());
        builder.setBuffNum(floorConfig.getBuffNum());
        return builder;
    }

    /**
     * buff config
     * @param buffConfig
     * @return
     */
    public static SonHaiProto.SonHaiBuffConfig.Builder buildSonHaiBuffConfig(SonHaiBuffConfig buffConfig, String language) {
        SonHaiProto.SonHaiBuffConfig.Builder builder = SonHaiProto.SonHaiBuffConfig.newBuilder();
        builder.setId(buffConfig.getId());
        builder.setIcon(buffConfig.getIcon());
        builder.setBuffType(buffConfig.getBuffType());
        builder.setName(ServerLanguageMgr.getContent(buffConfig.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(buffConfig.getDesc(), language));
        builder.setLevel(buffConfig.getLevel());
        builder.setParam(buffConfig.getParam());
        builder.setUpgradeParam(buffConfig.getUpgradeParam());
        builder.setNum(buffConfig.getNum());
        return builder;
    }

    /**
     * 怪 config
     * @param monsterConfig
     * @return
     */
    public static SonHaiProto.SonHaiMonsterConfig.Builder buildSonHaiMonsterConfig(SonHaiMonsterConfig monsterConfig, String language) {
        SonHaiProto.SonHaiMonsterConfig.Builder builder = SonHaiProto.SonHaiMonsterConfig.newBuilder();
        builder.setId(monsterConfig.getId());
        builder.setIcon(monsterConfig.getIcon());
        builder.setName(ServerLanguageMgr.getContent(monsterConfig.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(monsterConfig.getDesc(), language));
        builder.setParam(monsterConfig.getParam());
        builder.setLevel(monsterConfig.getLevel());
        return builder;
    }

    /**
     * 蛋 config
     * @param eggConfig
     * @return
     */
    public static SonHaiProto.SonHaiEggConfig.Builder buildSonHaiEggConfig(SonHaiEggConfig eggConfig, String language) {
        SonHaiProto.SonHaiEggConfig.Builder builder = SonHaiProto.SonHaiEggConfig.newBuilder();
        builder.setId(eggConfig.getId());
        builder.setIcon(eggConfig.getIcon());
        builder.setName(ServerLanguageMgr.getContent(eggConfig.getName(), language));
        builder.setMonster(eggConfig.getMonster());
        builder.setEventDesc(ServerLanguageMgr.getContent(eggConfig.getEventDesc(), language));
        builder.setDesc(ServerLanguageMgr.getContent(eggConfig.getDesc(), language));
        builder.setLevel(eggConfig.getLevel());
        builder.setParam(eggConfig.getParam());
        builder.setWeight(eggConfig.getWeight());
        builder.setReward(eggConfig.getReward());
        return builder;
    }

    /**
     * 地图 config
     * @param mapConfig
     * @return
     */
    public static SonHaiProto.SonHaiMapConfig.Builder buildSonHaiMapConfig(SonHaiMapConfig mapConfig) {
        SonHaiProto.SonHaiMapConfig.Builder builder = SonHaiProto.SonHaiMapConfig.newBuilder();
        builder.setId(mapConfig.getId());
        builder.setParam(mapConfig.getParam());
        builder.setMaxX(mapConfig.getMaxX());
        builder.setMaxY(mapConfig.getMaxY());
        return builder;
    }

    /**
     * 构造 区服玩家数据
     * @param serverUserData
     * @return
     */
    public static SonHaiProto.SonHaiServerUserData.Builder buildSonHaiServerUserData(SonHaiServerUserData serverUserData) {
        SonHaiProto.SonHaiServerUserData.Builder builder = SonHaiProto.SonHaiServerUserData.newBuilder();
        builder.setActivityId(serverUserData.getActivityId());
        builder.setUserId(serverUserData.getUserId());
        for (SonHaiUserMallData mallData : serverUserData.getMallDataMap().values()) {
            SonHaiProto.SonHaiMallData.Builder mallDataBuilder = buildSonHaiMallData(mallData);
            builder.addMallData(mallDataBuilder);
        }
        return builder;
    }

    /**
     * 构造 触发礼包数据
     * @param mallData
     * @return
     */
    public static SonHaiProto.SonHaiMallData.Builder buildSonHaiMallData(SonHaiUserMallData mallData) {
        SonHaiProto.SonHaiMallData.Builder builder = SonHaiProto.SonHaiMallData.newBuilder();
        builder.setMallId(mallData.getMallId());
        builder.setNum(mallData.getNum());
        builder.setEffectTime(mallData.getEffectTime());
        return builder;
    }
}
